/*
 * (#)TimesUtils.java 1.0 2013-9-27 2013-9-27 GMT+08:00
 */
package com.example.camera;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author guoshijie
 * @version $1.0, 2013-9-27 2013-9-27 GMT+08:00
 * @since jdk1.7.0_17
 */
public class TimesUtils {
	/**
	 * 拍摄倒计时 时间
	 */
	public static String format(int i) {
		String s = i + "";
		if (s.length() == 1) {
			s = "0" + s;
		}
		return s;
	}

	/**
	 * 得到 小时 分钟 秒
	 * @param a
	 * @return
	 */
	public static String getTime(int a) {
		int h = 0;
		int m = 0;
		int s = 0;
		String hh = "";
		String mm = "";
		String ss = "";
		h = a / 3600;
		m = (a - h * 3600) / 60;
		s = a - (h * 3600) - (m * 60);
		if (h < 10) {
			hh = "0" + h;
		} else {
			hh = h + "";
		}
		if (m < 10) {
			mm = "0" + m;
		} else {
			mm = m + "";
		}
		if (s < 10) {
			ss = "0" + s;
		} else {
			ss = s + "";
		}
		return  hh+":"+mm + ":" + ss;
	}
		
	/**
	 * 当前时间转为 月日 时分
	 */
	 public static String long2date(long datelong) {
		  SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
		  Date date = new Date();
		  date.setTime(datelong*1000);
		  return sdf.format(date);
		 }
}
